﻿//using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.UI;
//using System.Web.UI.WebControls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;
using System.Data;
using Eassets.Layered.Domain;
using Eassets.Service;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using Eassets.UI;
namespace Eassets.UI
{
    public partial class Eassets : System.Web.UI.MasterPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (Session[Global.KeyLoginUserStakeholderId] != null)
            {
                // SecurityGroupScreenService securityGroupScreenService = new SecurityGroupScreenService();

                string frmName = "";
                int exsist = 0;
                frmName = Page.AppRelativeVirtualPath.Substring(8);
                frmName = frmName.Substring(0, frmName.LastIndexOf("."));
                //exsist = securityGroupScreenService.CheckExist(1,Convert.ToInt64(Session[Global.KeyLoginUserStakeholderId]),frmName,Convert.ToInt64(Session[Global.KeyCurrentCompanyId]));
                if (exsist == 0 && frmName != "EcorpHome")
                {
                    Response.Redirect("ReferenceHome.aspx");
                }
                else
                    Response.Redirect("ReferenceHome.aspx");
                //LoadNavigationMenu();
            }


            if (!IsPostBack)
            {
                try
                {
                    //LoadNavigationMenu();
                    if (Session["MyAccordion.SelectedIndex"] != null)
                    {
                        accordionModuleMenu.SelectedIndex = (int)Session["MyAccordion.SelectedIndex"];
                    }
                    if (Session["AccordionSubMenu.SelectedIndex"] != null && Session["SelectedSubMenuAccordionId"] != null)
                    {
                        ((Accordion)(accordionModuleMenu.FindControl(Session["SelectedSubMenuAccordionId"].ToString()))).SelectedIndex = (int)Session["AccordionSubMenu.SelectedIndex"];
                    }
                }
                catch (Exception exception)
                {
                    accordionModuleMenu.SelectedIndex = 0;
                    //((Accordion)((LinkButton)sender).Parent.Parent.Parent).SelectedIndex = -1;
                    //throw;
                }
            }

            String[] arrayTreePrograms = new string[8];
            arrayTreePrograms[0] = "FixedAssetCategories.aspx";
            arrayTreePrograms[1] = "FixedAssetForm.aspx";
            arrayTreePrograms[2] = "AssetItemDetailsForm.aspx";
            arrayTreePrograms[3] = "~/FixedAssetCategories.aspx";
            //arrayTreePrograms[4] = "~/Ecorp/PositionHierarchy.aspx";
            //arrayTreePrograms[5] = "~/Ecorp/CompanyPositionStructureForm.aspx";
            //arrayTreePrograms[6] = "~/Ecorp/FixedAssetCategoriesForm.aspx";
            //arrayTreePrograms[7] = "~/Ecorp/ProductCategoryForm.aspx";

            //Response.Write(Page.Request.RawUrl + "," + Page.Request.Path + "," + Page.Request.CurrentExecutionFilePath + "," + Page.Request.AppRelativeCurrentExecutionFilePath);
            //if (arrayTreePrograms.Contains(Page.Request.AppRelativeCurrentExecutionFilePath))
            //{
            //    tabContainerMenuTree.ActiveTabIndex = 1;
            //}
            //else if (tabContainerMenuTree.Tabs.Count > 1)
            //{
            //    tabContainerMenuTree.Tabs.RemoveAt(1);
            //}
            if (arrayTreePrograms.Contains(Page.Request.AppRelativeCurrentExecutionFilePath))
            {
                tabContainerMenuTree.ActiveTabIndex = 1;
            }
            else if (tabContainerMenuTree.Tabs.Count > 1)
            {
                tabContainerMenuTree.Tabs.RemoveAt(1);
            }

        }

        protected void MenuLinkButto_OnClick(object sender, EventArgs e)
        {
            Session["MyAccordion.SelectedIndex"] = accordionModuleMenu.SelectedIndex;
            Response.Redirect(((LinkButton)sender).CommandArgument);
        }

        //protected void LinkButtonAssetCategory_OnClick(object sender, EventArgs e)
        //{
        //    Response.Redirect("FixedAssetCategories.aspx");
        //}

        protected void AssetCategory_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("FixedAssetCategories.aspx");
        }

        protected void FixedAsset_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("FixedAssetForm.aspx");
        }

        protected void AssetItemDetails_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("AssetItemDetailsForm.aspx");
        }

        protected void CompanyAssets_Click(object sender, EventArgs e)
        {
            Response.Redirect("CompanyAssetsForm.aspx");
        }

        protected void OrganizationLevelAsset_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("OrganizationLevelAssetForm.aspx");
        }

         protected void AssetRequisition_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("AssetRequisitionForm.aspx");
        }

        protected void linkLogOut_Click(object sender, EventArgs e)
        {
            Response.Redirect("Default.aspx");
        }

        protected void AssetAquisition_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("AssetAquisitionForm.aspx");
        }

        protected void AssetDisposal_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("AssetDisposalForm.aspx");
        }

        protected void AssetRevaluation_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("AssetRevaluationForm.aspx");
        }
        protected void AssetTransferOut_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("AssetTransferOutForm.aspx");
        }

        protected void EmployeeDetails_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("EmployeeDetails.aspx");
        }

        protected void CompanyDetails_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("CompanyDetailsForm.aspx");
        }

        protected void Company_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("CompanyForm.aspx");
        }

        protected void ChangeCustodian_OnClick(object sender, EventArgs e)
        {
            Response.Redirect("ChangeAssetCustodianForm.aspx");
        }
    }
}